package com.company.app.entities;

import java.io.Serializable;
import java.util.Date;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.google.code.ssm.api.CacheKeyMethod;

/**
 * The Class Client.
 */
@XmlType(name="Customer", 
		namespace = "http://entities.app.company.com", 
		propOrder = { "id", "name", "email", "address", "dateCreated" })
@XmlRootElement(name = "Customer")
public class Customer implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 721578554618136175L;

	/** The id. */
	private Long id;

	/** The name. */
	private String name;

	/** The email. */
	private String email;

	/** The adress. */
	private String address;

	/** The date created. */
	private Date dateCreated;

	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	
	public Long getId() {
		return id;
	}
	
	/**
	 * Sets the id.
	 * 
	 * @param id
	 *            the new id
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	@XmlElement(required = true)
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the email.
	 * 
	 * @return the email
	 */
	@XmlElement(required = true)
	public String getEmail() {
		return email;
	}

	/**
	 * Sets the email.
	 * 
	 * @param email
	 *            the new email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Gets the address.
	 * 
	 * @return the address
	 */
	@XmlElement(required = true)
	public String getAddress() {
		return address;
	}

	/**
	 * Sets the address.
	 * 
	 * @param address
	 *            the new address
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * Gets the date created.
	 * 
	 * @return the date created
	 */
	public Date getDateCreated() {
		return dateCreated;
	}

	/**
	 * Sets the date created.
	 * 
	 * @param dateCreated
	 *            the new date created
	 */
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	/*
	 * (non-Javadoc)
	 * Also used to generate MEMCACHED key
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Customer{id=" + this.getId() + ",name=" + this.getName()
				+ ",email=" + this.getEmail() + ",address="
				+ this.getAddress() + "dateCreated,=" + this.getDateCreated()
				+ "}";
	}
	
	/* YOU CAN USE THIS ANNOTATIONS FOR GENERATE YOUR OWN KEY WITH A ESPECIFC PATTERN
	 *
	 **/
	@CacheKeyMethod
	public String getIdForCache(){
		return this.getId()!=null ? this.getId().toString() : "NULL";
	}

}